<template>
  <div>
    <SpRouterView class="merchantList">
      <div class="action-container">
        <el-button type="primary" icon="ecx-icon icon-xinzeng" @click="addMerchant">
          新增代理商
        </el-button>
      </div>

      <SpFilterForm :model="formParams" @onSearch="onSearch" @onReset="onSearch">
        <SpFilterFormItem prop="agents_name" label="代理商姓名:">
          <el-input v-model="formParams.agents_name" placeholder="代理商姓名" />
        </SpFilterFormItem>
        <SpFilterFormItem prop="phone" label="电话:">
          <el-input v-model="formParams.phone" placeholder="请输入电话" />
        </SpFilterFormItem>
        <SpFilterFormItem prop="recruitment" label="招募人:">
          <el-input v-model="formParams.recruitment" placeholder="请输入所属招募人" />
        </SpFilterFormItem>
      </SpFilterForm>

      <el-table v-loading="loading" border :data="list"  style="width:100%" element-loading-text="数据加载中" >
        <el-table-column label="操作" width="90" fixed>
          <template slot-scope="{row}">
            <el-button type="text" class="btn-gap" @click="editItem(row)">
              编辑
            </el-button>
            <el-popover placement="right" width="unset" trigger="hover">
              <div class="operating-icons">
                <el-button icon="edit" type="text" class="btn-gap" @click="configAreaShow(row)">
                  分配区域
                </el-button>
                <el-button icon="edit" type="text" @click="go('/sellers/storemanager/list',{seek_agent_id:row.agent_id})">
                  查看商家
                </el-button>
                <el-button icon="edit" type="text" @click="cashOutShow(row)">
                  佣金提现
                </el-button>
                <el-button icon="edit" type="text" @click="cashOutListShow(row)">
                  提现记录
                </el-button>
                <el-button icon="edit" type="text" @click="go(matchHidePage('commission'),{ agentId:row.agent_id })">
                  佣金明细
                </el-button>
                <el-button icon="edit" type="text" @click="bindUserShow(row)">
                  绑定会员
                </el-button>
                <el-button icon="edit" type="text" @click="go('/marketing/popularize/popularizelist',{agent_id:row.agent_id})">
                  查看团长
                </el-button>
                <!-- <el-button icon="edit" type="text" @click="deleteAgent(row)">
                  删除
                </el-button> -->
              </div>
              <el-button slot="reference" type="text">
                <i class="iconfont icon-angle-double-right" />
              </el-button>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column prop="agent_id" label="ID" width="90" />
        <el-table-column prop="agents_name" label="代理商姓名" width="95" />
        <el-table-column prop="phone" label="电话" width="115" />
        <el-table-column prop="province" label="所在省市区" min-width="120" >
          <template slot-scope="{row}">
            {{row.province + row.city + row.area}}
          </template>
        </el-table-column>
        <el-table-column prop="address" label="详细地址" min-width="100" show-overflow-tooltip />
        <el-table-column prop="terms" label="代理商入驻费" width="110" >
          <template slot-scope="{row}">
            <!-- {{row.terms}}元 -->
            {{row.terms | fenToYuan}}元
          </template>
        </el-table-column>
        <el-table-column prop="id" label="代理区域" width="80">
          <template slot-scope="{row}">
            <span @click="configAreaShow(row)" style="color:#409EFF;cursor:pointer">查看</span>
          </template>
        </el-table-column>
        <el-table-column prop="user_total" label="已招募商家" width="95" />
        <el-table-column prop="brokerage_total" label="总佣金">
          <template slot-scope="{row}">
            <!-- {{Number(row.brokerage_total/100).toFixed(2)}} -->
            {{row.brokerage_total | fenToYuan | keepTwoDecimalFull}}元
          </template>
        </el-table-column>
        <el-table-column prop="jobs" label="所属招募人/工号" width="130" >
          <template slot-scope="{row}">
            {{row.recruitment}}/{{row.jobs}}
          </template>
        </el-table-column>
        <el-table-column prop="members" label="绑定会员" min-width="90">
          <template slot-scope="{row}">
            {{row.members?row.members.mobile:''}}
          </template>
        </el-table-column>
        <el-table-column prop="is_enable" label="禁用" width="70" align="center">
          <template slot-scope="{row}">
            <el-switch 
              activeColor="#ff4949"
              active-value="0"
              inactive-value="1"
              :value="row.is_enable"
              @change="v=>{row.is_enable = v;updateAgentStatus(row,v)}"
              />
          </template>
        </el-table-column>
        <el-table-column prop="created" label="创建时间" width="100" align="center" >
          <template slot-scope="{row}">
            {{row.created | formatDataTime('YYYY/MM/DD')}}
          </template>
        </el-table-column>
        <el-table-column prop="is_allocation" label="是否分配区域" width="105" align="center" >
          <template slot-scope="{row}">
            <!-- {{row.is_allocation == '1'?'已分配':'未分配'}} -->
            <el-tag v-if="row.is_allocation == '1'">已分配</el-tag>
            <el-tag v-else type="info">未分配</el-tag>
          </template>
        </el-table-column>
      </el-table>
      <div class="content-padded content-center">
        <el-pagination background layout="total, sizes, prev, pager, next, jumper" :current-page.sync="page.pageIndex"
          :total="total_count" :page-size="page.pageSize" @size-change="onSizeChange" @current-change="onCurrentChange" />
      </div>

    </SpRouterView>

    <!-- 区域分配 -->
    <el-dialog
      title="分配区域"
      :visible.sync="configAreaVisible"
      :before-close="configAreaCancel"
      width="800px"
    >
      <template>
        <el-form
          ref="configAreaForm"
          :model="configAreaForm"
          class="demo-ruleForm"
          label-width="120px"
        >
          <el-form-item label="代理商姓名:">
            {{configAreaForm.agents_name || ''}}
          </el-form-item>
          <el-form-item label="电话:">
            {{configAreaForm.phone || ''}}
          </el-form-item>
          <el-form-item label="招募人:">
            {{configAreaForm.recruitment || ''}}
          </el-form-item>
          <el-divider></el-divider>
          <el-row v-for="(item,index) in configAreaForm.list" :key="item.agent_address_id || item.key" :gutter="10">
            <el-col :span="12">
              <el-form-item label="" label-width="0" required 
                :rules="[
                  { required: true, message: '请选择省市区' }
                ]"
                :prop="'list.' + index + '.regions_id'"
              >
                <!-- {{'item.' + (item.agent_address_id || item.key) + '.regions_id'}} -->
                <el-cascader
                  v-model="item.regions_id"
                  style="width: 100%"
                  :options="AreaJson"
                  clearable
                  :props="{ value: 'value', label: 'label', children: 'children' }"
                  @change="e=>regionChange(e,index)"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="" label-width="0" required 
                :rules="[
                  { required: true, message: '请输入街道' }
                ]"
                :prop="'list.' + index + '.address'"
              >
                <el-input v-model="item.address" placeholder="请输入街道"></el-input>
              </el-form-item>
            </el-col>
            <!-- <el-col :span="1">
              <i @click="delArea(index)" class="el-icon-delete" style="font-size: 16px; line-height: 40px;"></i>
            </el-col> -->
          </el-row>
          <!-- <el-row :gutter="10">
            <el-col :span="12">
              <el-form-item label="" label-width="0">
                <el-cascader
                  v-model="configAreaForm.list[0].regions_id"
                  style="width: 100%"
                  :options="AreaJson"
                  clearable
                  :props="{ value: 'value', label: 'label', children: 'children' }"
                  @change="e=>regionChange(e,0)"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="" label-width="0">
                <el-input v-model="configAreaForm.list[0].address" placeholder="请输入街道"></el-input>
              </el-form-item>
            </el-col>
          </el-row> -->
          <el-form-item label="" label-width="0">
            <div style="float: right;">
              <el-button @click="addArea">新增区域</el-button>
            </div>
          </el-form-item>

        </el-form>
      </template>
      <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button @click.native="configAreaCancel">
          取消
        </el-button>
        <el-button
          type="primary"
          @click="configAreaSubmit"
          :disabled="isSub"
        >
          提交
        </el-button>
      </div>
    </el-dialog>
    <!-- 佣金提现 -->
    <el-dialog
      title="佣金提现"
      :visible.sync="cashOutVisible"
      :before-close="cashOutCancel"
      width="800px"
    >
      <template>
        <el-form ref="cashOutForm" label-width="180px" :model="cashOutForm" @submit.native.prevent>
          <el-form-item class="form-item-detail" label="代理商姓名：">
            {{row.agents_name || ''}}
          </el-form-item>
          <el-form-item class="form-item-detail" label="电话：">
            {{row.phone || ''}}
          </el-form-item>
          <el-form-item class="form-item-detail" label="总佣金（元）：">
            {{(row.brokerage_total || 0) | fenToYuan | keepTwoDecimalFull}}
          </el-form-item>
          <el-form-item class="form-item-detail" label="可提现佣金（元）：">
            <span style="color:#F00">{{(row.withdrawal_brokerage || 0)  | fenToYuan | keepTwoDecimalFull}}</span>
          </el-form-item>
          <el-form-item class="form-item-detail" label="开户行：">
            {{row.bank_name || ''}}
          </el-form-item>
          <el-form-item label="卡号：">
            {{row.card_number || ''}}
          </el-form-item>
          <el-form-item prop="money" label="转账金额" required
            :rules="[
              { required: true, message: '请输入转账金额' }
            ]"
          >
            <el-input placeholder="请输入转账金额" type="number" v-model="cashOutForm.money" autofocus="true" min="0.01">
              <template slot="append">元</template>
            </el-input>
          </el-form-item>

        </el-form>
      </template>
      <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button @click.native="cashOutCancel">
          取消
        </el-button>
        <el-button
          type="primary"
          @click="cashOutSubmit"
          :disabled="isSub || (Number(row.withdrawal_brokerage)<=0 || Number(row.withdrawal_brokerage)<Number(cashOutForm.money*100))"
        >
          提交
        </el-button>
      </div>
    </el-dialog>
    <!-- 提现记录 -->
    <el-dialog
      title="提现记录"
      :visible.sync="cashOutListVisible"
      :before-close="cashOutListCancel"
      width="800px"
    >
      <template>
        <el-form label-width="180px">
          <el-form-item class="form-item-detail" label="代理商姓名：">
            {{row.agents_name || ''}}
          </el-form-item>
          <el-form-item class="form-item-detail" label="电话：">
            {{row.phone || ''}}
          </el-form-item>
          <el-form-item class="form-item-detail" label="总佣金（元）：">
            {{(row.brokerage_total || 0) | fenToYuan | keepTwoDecimalFull}}
          </el-form-item>
          <el-form-item class="form-item-detail" label="可提现佣金（元）：">
            <span style="color:#F00">{{(row.withdrawal_brokerage || 0) | fenToYuan | keepTwoDecimalFull}}</span>
          </el-form-item>
        </el-form>
        <el-divider></el-divider>
        <el-table :data="cashOutList" style="width: 100%;max-height: 500px;">
          <el-table-column prop="date" label="提现时间">
            <template slot-scope="{row}">
              <span>{{ row.created | datetime('YYYY-MM-DD HH:mm') }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="money" label="提现金额（元）">
            <template slot-scope="{row}">
              <span>{{ row.money / 100 }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="status" label="提现状态">
            <template slot-scope="{row}">
              <el-tag
                v-if="row.status == 1"
                type="success"
              >
                已提现
              </el-tag>
              <el-tag
                v-else
                type="info"
              >
                处理中
              </el-tag>
              <!-- <span>{{ row.status == 1?'已提现':'处理中' }}</span> -->
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          background
          layout="total, sizes, prev, pager, next"
          hide-on-single-page
          style="margin-top: 10px;"
          :page-sizes="[cashQuery.pageSize]"
          :total="cash_total_count"
          :page-size="cashQuery.pageSize"
          @current-change="cashOutCurrentChange"
        />
      </template>
      <!-- <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button @click.native="cashOutListCancel">
          取消
        </el-button>
        <el-button
          type="primary"
          @click="cashOutListCancelsubmit"
        >
          提交
        </el-button>
      </div> -->
    </el-dialog>
    <!-- 佣金明细 -->
    <el-dialog
      title="佣金明细"
      :visible.sync="commissionVisible"
      :before-close="commissionCancel"
      width="800px"
    >
      <template>
        佣金明细
      </template>
      <!-- <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button @click.native="commissionCancel">
          取消
        </el-button>
        <el-button
          type="primary"
          @click="commissionCancelsubmit"
        >
          提交
        </el-button>
      </div> -->
    </el-dialog>
    <!-- 绑定会员 -->
    <el-dialog
      title="绑定会员"
      :visible.sync="bindUserVisible"
      :before-close="bindUserCancel"
      width="800px"
    >
      <template>
        <el-form ref="bindUserForm" label-width="180px" :model="bindUserForm" @submit.native.prevent>
          <el-form-item class="form-item-detail" label="代理商姓名：">
            {{row.agents_name || ''}}
          </el-form-item>
          <el-form-item class="form-item-detail" label="电话：">
            {{row.phone || ''}}
          </el-form-item>
          <el-form-item class="form-item-detail">
            <el-alert title="绑定的会员必须为已经授权手机号的会员" type="info" show-icon style="height: 30px;margin-bottom: 5px;" />
          </el-form-item>
          <el-form-item prop="userPhone" label="会员手机号" required
            :rules="[
              { required: true,trigger: 'blur',validator:validateMobile },
            ]"
          >
            <el-input placeholder="请输入手机号" type="text" v-model="bindUserForm.userPhone" autofocus="true"></el-input>
          </el-form-item>

        </el-form>
      </template>
      <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button @click.native="bindUserCancel">
          取消
        </el-button>
        <el-button
          type="primary"
          @click="bindUserSubmit"
          :disabled="isSub"
        >
          提交
        </el-button>
      </div>
    </el-dialog>


  </div>
</template>

<script>
// import { setCommodityAudit, setMerchantsState } from '@/api/mall/marketing'
// import { PICKER_DATE_OPTIONS } from '@/consts'
// import { createSetting } from '@shopex/finder'
import { deleteAgent } from '@/api/agent.js'
import { getArea } from '@/api/mall/marketing.js'
import { isMobile } from '@/utils/validate'
// import moment from 'moment'
import { pageMixin } from '@/mixins'
import { mapGetters } from 'vuex'
export default {
  mixins: [pageMixin],
  data() {
    return {
      // defaultTime: ['00:00:00', '23:59:59'],
      // pickerOptions: PICKER_DATE_OPTIONS,
      formParams: {
        legal_name: '',
        phone:'',
        recruitment:'',
        // merchant_name: '',
        // legal_mobile: '',
        // time_start: []
      },
      // datapass_block: 0,
      // 列表
      loading: false,
      list: [],
      total_count: 0,
      isSub:false,
      // 区域分配
      configAreaVisible:false,
      configAreaForm:{
        list:[
          {
            key:Date.now(),
          }
        ],
      },
      // 佣金提现
      cashOutVisible:false,
      cashOutForm:{},
      // 提现记录
      cashOutListVisible:false,
      cashOutList:[],
      cashQuery:{
        page:1,
        pageSize:10,
      },
      cash_total_count:0,
      // 佣金明细
      commissionVisible:false,
      AreaJson: [],
      row:{},
      // 绑定会员
      bindUserVisible:false,
      bindUserForm:{userPhone:''},
      // requireRule:[
      //   { required: true, message: '请输入' }
      // ],
    }
  },

  watch: {
    $route(to, from) {
      if (to.meta?.routeId === 'agent-id') {
        this.fetchList()
      }
    }
  },
  mounted(){
    this.getAreaList()
    this.fetchList();
  },
  methods: {
    // 代理商列表查询
    fetchList() {
      this.loading = true
      const { pageIndex: page, pageSize } = this.page
      let params = {
        page,
        pageSize,
        ...this.formParams
      }
      this.$api.agent.getTheAgentList(params).then((res) => {
        console.log('getTheAgentList',res)
        this.list = res.list
        this.total_count = Number(res.total_count)
        // this.datapass_block = res.data.data.datapass_block
        this.loading = false
      })
    },
    // 编辑代理商
    editItem(item){
      this.$router.push({
        path: this.matchHidePage('editor'),
        query: { type: 'edit', agentId: item.agent_id }
      })
    },
    // 查询
    onSearch() {
      // this.$refs.finder.refresh(true)
      this.fetchList()
    },
    // 新增代理商
    addMerchant() {
      this.$router.push({ path: this.matchHidePage('editor'), query: { type: 'add' } })
    },
    // 删除代理商
    async deleteAgent(item){
      await this.$confirm(`是否确认删除代理商？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
      const { status } = await deleteAgent(item.agent_id)
      if (status) {
        this.$message.success('删除成功')
        // this.$refs.finder.refresh()
        this.fetchList();
      } else {
        this.$message.success('失败')
      }
    },
    // 修改状态 start
    async updateAgentStatus(row,v){
      await this.$api.agent.updateAgentStatus({agent_id:row.agent_id,is_enable:v})
    },
    // 修改状态 end
    // 区域配置 start
    async configAreaShow(col){
      let list = [];
      if(col.is_allocation == 1)
      list = await this.$api.agent.getAgentAreaList({agent_id:col.agent_id});
      console.log('getAgentAreaList',list)

      this.configAreaVisible = true
      this.configAreaForm.agent_id = col.agent_id
      this.configAreaForm.agents_name = col.agents_name
      this.configAreaForm.phone = col.phone
      this.configAreaForm.recruitment = col.recruitment
      let item = {
        // regions_id:'',
        // regions_id:'430111',
        // regions_id:["430000","430100","430111"],
        agent_id:col.agent_id,
        regions_id:"",
        key:Date.now(),
      }
      this.configAreaForm.list = list.length?list:[
        item
      ]
    },
    configAreaCancel () {
      // console.log('configAreaCancel')
      this.configAreaVisible = false
      this.configAreaForm = {
        list:[],
      };
      // this.form.operator_type = 'staff'
      // this.operator_id = ''
      // this.form.login_name = ''
      // this.form.mobile = ''
      // this.form.username = ''
      // this.form.password = ''
      // this.form.role_id = []
      // this.form.distributor_ids = []
      // this.form.shop_ids = []
      // this.relDistributors = []
      // this.relShops = []
    },
    configAreaSubmit () {
      this.$refs.configAreaForm.validate(async (valid)=>{
        if(valid){
          console.log('configAreaSubmit',this.configAreaForm)
          let list = this.configAreaForm.list.map(item=>{
            return {
              ...item,
              province:item?.regions?.[0],
              city:item?.regions?.[1],
              area:item?.regions?.[2],
            }
          });
          this.configAreaForm
          try{
            this.isSub = true;
            await this.$api.agent.saveAgentArea(list)
            this.configAreaCancel();
            this.$message({
              message: '操作成功',
              type: 'success'
            });
            this.isSub = false;
            this.fetchList();
          }
          catch(e){
            this.isSub = false;
          }
        }
        else{
          console.log('error submit!!');
          return false;
        }
      })
    },
    addArea(){
      this.configAreaForm.list.push({
        agent_id:this.configAreaForm.agent_id,
        regions_id:'',
        address:'',
        key:Date.now(),
      })
    },
    delArea(index){
      this.configAreaForm.list.splice(index, 1)
    },
    async getAreaList() {
      const result = await getArea()
      this.AreaJson = result.data.data
    },
    regionChange(value,index) {
      // console.log(value)
      // if(!value)return;
      var vals = this.getCascaderObj(value, this.AreaJson)
      if (vals.length > 0) {
        // this.configAreaForm.regions = [vals[0].label, vals[1].label, vals[2].label]
        this.configAreaForm.list[index].regions = [vals[0].label, vals[1].label, vals[2].label]
      } else {
        // this.configAreaForm.regions = []
        this.configAreaForm.list[index].regions = []
      }
      // console.log(this.configAreaForm.regions)
    },
    getCascaderObj(val, opt) {
      if(!val)return null;
      return val.map(function (value) {
        for (var itm of opt) {
          if (itm.value === value) {
            opt = itm.children
            return itm
          }
        }
        return null
      })
    },
    // 区域配置 end
    // 佣金提现 cashOut start
    async cashOutShow(col){
      let detail = await this.$api.agent.getTheAgent({},col.agent_id)
      this.row = {
        ...col,
        // withdrawal_brokerage:600,
        withdrawal_brokerage:detail.withdrawal_brokerage,
      };
      this.cashOutVisible = true
      console.log('detail',detail,this.row)
    },
    cashOutCancel () {
      // console.log('cashOutCancel')
      this.cashOutVisible = false
      this.cashOutForm = {};
      this.row = {};
      this.cashOutList = []
      this.cash_total_count = 0
    },
    cashOutSubmit () {
      this.$refs.cashOutForm.validate(async (valid)=>{
        if(valid){
          console.log('cashOutSubmit',this.cashOutForm)
          if(Number(this.cashOutForm.money)<=0){
            this.$message.error('请输入有效金额')
            return;
          }
          let _p = { 
            // ...this.cashOutForm,
            money:parseInt(this.cashOutForm.money * 100),
            agent_id:this.row.agent_id,
            bank_name:this.row.bank_name,
            card_number:this.row.card_number,
            mobile:this.row.phone,
          }
          try{
            this.isSub = true;
            await this.$api.agent.agentsWithdrawal(_p)
            this.cashOutCancel();
            this.$message({
              message: '操作成功',
              type: 'success'
            });
            this.isSub = false;
          }
          catch(e){
            this.isSub = false;
          }
        }
        else{
          console.log('error submit!!');
          return false;
        }
      })
    },
    // 佣金提现 end
    // 提现记录 cashOutList start
    async cashOutListShow(col){
      this.cashOutListVisible = true
      this.row = col;
      this.$api.agent.getTheAgent({},col.agent_id).then(detail=>{
        this.row.withdrawal_brokerage = detail.withdrawal_brokerage
      })
      this.cashQuery.agent_id = col.agent_id
      // this.$api.agent.getAgentsWithdrawalList(this.cashQuery).then(res=>{
      //   this.cashOutList = res.info.list
      // })
      this.getAgentsWithdrawalList()
    },
    getAgentsWithdrawalList(){
      this.$api.agent.getAgentsWithdrawalList(this.cashQuery).then(res=>{
        this.cashOutList = res.info.list
        this.cash_total_count = res.info.total_count
      })
    },
    cashOutListCancel () {
      // console.log('cashOutListCancel')
      this.cashOutListVisible = false
      this.row = {};
      // this.cashOutListForm = {};
    },
    cashOutCurrentChange(page_num){
      this.cashQuery.page = page_num
      this.getAgentsWithdrawalList()
    },
    // 提现记录 end
    // 佣金明细 commission start
    commissionShow(col){
      this.commissionVisible = true
      this.row = col;
    },
    commissionCancel () {
      // console.log('commissionCancel')
      this.commissionVisible = false
      this.row = {};
      // this.commissionForm = {};
    },
    // 佣金明细 end
    // 绑定会员 bindUser start
    async bindUserShow(col){
      this.row = {
        ...col,
      };
      if(col?.members?.mobile){
        this.bindUserForm = {userPhone:col.members.mobile};
      }
      this.bindUserVisible = true
      // console.log('detail',detail,this.row)
    },
    bindUserCancel () {
      // console.log('bindUserCancel')
      this.bindUserVisible = false
      this.bindUserForm = {userPhone:''};
      this.row = {};
    },
    bindUserSubmit () {
      this.$refs.bindUserForm.validate(async (valid)=>{
        if(valid){
          console.log('bindUserSubmit',this.bindUserForm)
          let _p = { 
            // ...this.bindUserForm,
            // money:parseInt(this.bindUserForm.money * 100),
            agent_id:this.row.agent_id,
            mobile:this.bindUserForm.userPhone,
            // bank_name:this.row.bank_name,
            // card_number:this.row.card_number,
            // mobile:this.row.phone,
          }
          console.log('bindUserSubmit',_p)
          try{
            this.isSub = true;
            await this.$api.agent.agentsBindMember(_p)
            this.bindUserCancel();
            this.$message({
              message: '操作成功',
              type: 'success'
            });
            this.fetchList()
            this.isSub = false
          }catch(e){
            this.isSub = false
          }
        }
        else{
          console.log('error submit!!');
          return false;
        }
      })
    },
    validateMobile(rule, value, callback){
      if (!isMobile(value)) {
        callback(new Error('请输入正确的合法手机号'))
      } else {
        callback()
      }
    },
    // 绑定会员 end
    go(url,_p){
      this.$router.push({
        path: url,
        query: _p
      })
    },
  },
  computed: {
    ...mapGetters(['wheight'])
  }
}
</script>

<style lang="scss">
.merchantList {
  .yahh {
    color: #409eff;
  }
}
.form-item-detail{
  margin-bottom: 0;
}
.sp-filter-form {
  margin-bottom: 16px;
}
</style>
